import {
	IsIn,
	IsMobilePhone, IsNotEmpty,
	IsNumber,
	IsOptional,
	IsString
} from "class-validator";
import { GenderType, StatusValue } from "@/enum/common.enum";
import { ApiProperty } from "@nestjs/swagger";
import { $enum } from "ts-enum-util";

export class UpdateUserDto {
	@ApiProperty({ type: String, enum: $enum(GenderType).getValues(), description: "性别：1-男 2-女" })
	@IsNumber({}, { message: "status 类型错误，正确类型 number" })
	@IsIn([GenderType.MAN, GenderType.WOMAN], { message: "性别：1-男 2-女" })
	@IsOptional()
	gender: number;
	
	@ApiProperty({ type: String, description: "用户手机号码" })
	@IsString({ message: "photo 类型错误，正确类型 string" })
	@IsMobilePhone("zh-CN", { strictMode: false }, { message: "请输入正确的手机号" })
	// @IsPhoneNumber('CH', { message: '请输入正确的手机号' })
	@IsOptional()
	photo: string;
	
	@ApiProperty({ type: String, description: "用户地址" })
	@IsString({ message: "address 类型错误，正确类型 string" })
	@IsOptional()
	address: string;
	
	@IsOptional()
	balance: number;
	
	@ApiProperty({ type: String, description: "头像url" })
	@IsString({ message: "avatar 类型错误，正确类型 string" })
	@IsOptional()
	avatar: string;
	
	@ApiProperty({ type: String, enum: $enum(StatusValue).getValues(), description: "状态：0-禁用 1-启用" })
	@IsNumber({}, { message: "status 类型错误，正确类型 number" })
	@IsIn([StatusValue.NORMAL, StatusValue.FORBIDDEN], { message: "status 可选值0/1，分别表示有效禁用" })
	@IsOptional()
	status: number;
}

